<?php

namespace App\Http\Controllers\Talent;

use App\Http\Controllers\BaseController;
use App\Models\Message;
use App\Models\Talent;
use Illuminate\Http\Request;

class TalentController extends BaseController
{
    public function index()
    {

    }

    public function store(Request $request)
    {
        $param = $this->validate($request,[
            'company_name' => 'required',
            'contact_name' => 'required',
            'sex' => 'required|in:1,2',
            'contact_phone' => 'required',
        ]);

        $param['user_id'] = auth('api')->id();
        $job = Talent::query()->create($param);

        if ($job->getKey()){
            Message::query()->create([
                'type' => 3,
                'content' => $param['company_name']. '发布了猎聘咨询需求'
            ]);
            return $this->success();
        }

        return $this->error();
    }
}
